<template>
	<view class="page">
		<view v-if="hospital">
			<view>{{hospital.hospitalSynopsis}}</view>
			<mp-html :content="hospital.hospitalDetail"></mp-html>
		</view>
		<view v-else>{{text}}</view>
	</view>
</template>

<script>
	import {
		getHospitalDetails
	} from '@/apis/request.js';

	export default {
		data() {
			return {
				id: '',
				hospital: null,
				text: ''
			};
		},
		onLoad(options) {
			this.id = options.id || ''
			if (this.id) {
				this.getHospitalDetail();
			} else {
				this.text = uni.getStorageSync('gohospitalSynopsis') || ''
			}
		},
		onBackPress(e) {
			uni.removeStorageSync('gohospitalSynopsis')
		},
		methods: {
			getHospitalDetail() {
				uni.showLoading({
					title: '加载中'
				});
				let params = {
					hospitalId: this.id
				};
				getHospitalDetails(params).then(res => {
					this.hospital = res || {};
				}).finally(() => {
					uni.hideLoading();
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.page {
		padding: 0 20upx;
	}
</style>